package br.com.sig.business.service;

import java.io.Serializable;

import javax.ejb.Stateless;
import javax.inject.Named;

import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

@Named
@Stateless
public class EmailService implements Serializable {

	private static final long serialVersionUID = 2615629505391599132L;

	public void send(String to, String subject, String message) {
		Email email = new SimpleEmail();

		try {
			email.setHostName("smtp.mail.yahoo.com.br");
			email.setSmtpPort(485);			
			email.setSSLOnConnect(true);
			email.setStartTLSEnabled(true);
			email.setAuthentication("rafael_meireles@yahoo.com.br", "rafa0184");
			email.setFrom("rafael_meireles@yahoo.com.br");
			email.addTo(to);
			email.setSubject(subject);
			email.setMsg(message);
			email.send();
		} catch (EmailException e) {
			System.out.println(e.getMessage());
		} 
	}
}